package com.example.demo.controller;

import com.example.demo.Mappers.ZYAddDepositMapper;
import com.example.demo.beans.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018-07-02.
 */
@RestController
public class GetDepositRecordController {
    @Autowired
    private ZYAddDepositMapper mapper;
    @ResponseBody
   @RequestMapping(value = "GetDepositRecord",produces ={"application/xml"})
    public GetDepositRecordResponse getDeppost(@RequestBody GetDepositRecordRequest request)
    {
        if(request!=null)
    { List<YjjlBean> yjjlBeans=new ArrayList<>();
      yjjlBeans=mapper.getyjjl(request.getZyno());
      if(!yjjlBeans.isEmpty()){
        //  System .out.print("记录不为空");
        List<GetDepositRecordBean> beans=new ArrayList<>();
        for(int i=0;i<yjjlBeans.size();i++) {
            GetDepositRecordBean bean=new GetDepositRecordBean();
            bean.setHosTranNo(yjjlBeans.get(i).getYjjlid());
            bean.setOperDateTime(yjjlBeans.get(i).getYjrq());
            bean.setAmt(yjjlBeans.get(i).getYjje());
            bean.setPayTag(yjjlBeans.get(i).getZflxmc());
            bean.setTranNo(yjjlBeans.get(i).getYjjlid());
            bean.setOperator(yjjlBeans.get(i).getCzyxm());
            beans.add(bean);
        }
      GetDepositRecordResponse response=new GetDepositRecordResponse();
        response.setResultCode("0");
        response.setResultMsg("交易成功");
        response.setItems(beans);
        return  response;
    }
    else {
         // System .out.print("记录为空");
        GetDepositRecordResponse r=new GetDepositRecordResponse();
        r.setResultCode("0");
        r.setResultMsg("查询成功，但是系统没有找到您的预交信息，请您到窗口办理相关业务！");
        return  r;
    }}
    return  null;

    }
}
